package com.zhangwei.day38.utils;

import android.content.Context;

import com.lidroid.xutils.bitmap.BitmapDisplayConfig;
import com.lidroid.xutils.bitmap.BitmapGlobalConfig;
import com.lidroid.xutils.cache.MD5FileNameGenerator;
import com.zhangwei.day38.R;

/**
 * @author zhangwei
 * @version V1.0
 * @Title: Advanced
 * @Package com.zhangwei.day38.utils
 * @Description:
 * @date 15/10/20 上午11:08
 */

public class XutilsHelper {
    private static XutilsHelper helper = new XutilsHelper();




    private XutilsHelper() {

    }

    public static XutilsHelper getInstance() {
        return helper;
    }

    /**
     * 图片全局配置
     *
     * @param context
     */
    public void GonfigGlobalBitmap(Context context) {
        BitmapGlobalConfig config = BitmapGlobalConfig.getInstance(context, FileUtils.getSaveBitmapPath(context));
        config.setDiskCacheSize(100 * 1024 * 1024);
        config.setDefaultCacheExpiry(1000L * 60 * 60 * 24 * 30 * 12);
        config.setFileNameGenerator(new MD5FileNameGenerator());
    }

    public BitmapDisplayConfig getDefBitmapDisplayOption(Context context) {
        BitmapDisplayConfig config = new BitmapDisplayConfig();
        config.setLoadFailedDrawable(context.getResources().getDrawable(R.mipmap.ic_launcher));
        config.setLoadingDrawable(context.getResources().getDrawable(R.mipmap.ic_launcher));
        return config;
    }

}
